const router = require('koa-router')()
const UserController = require('../controller/user')
const UserStorageController = require('../controller/userStorage')
const MsgRobotController = require('../controller/msgRobot')
const userStorageController = new UserStorageController()
const userController = new UserController()
const msgRobot = new MsgRobotController()

router.use(userController.userFilter())

// 用户基础操作
router.post('/actions/login', userController.login())
router.post('/actions/registry', userController.registry())
router.post('/actions/changePassword', userController.changePassword())
router.get('/me', userController.getCurrentUser())
router.get('/logout', userController.logout())
router.post('/logout', userController.logout())

// 用户工作台
router.post('/actions/saveStorage', userStorageController.saveStorage())
router.post('/actions/loadStorage', userStorageController.loadStorage())
router.post('/actions/updateWorkbenches',
  userStorageController.updateWorkbenches())
router.post('/feedback', userController.feedback())

// 消息机器人
router.post('/actions/findAllMsgRobot', msgRobot.findAll())
router.post('/actions/createMsgRobot', msgRobot.create())
router.post('/actions/deleteMsgRobot', msgRobot.deleteById())
router.post('/actions/updateMsgRobot', msgRobot.update())

// 分享面板
router.post('/actions/createSharePanel', userStorageController.createSharePanel())
router.put('/actions/updateSharePanel', userStorageController.updateSharePanel())

// 用户行为日志
router.post('/log', userController.postActivity())

module.exports = router
